package 二维费用的背包问题;

import java.util.Scanner;

public class Main {
    static int N = 110;
    static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int V = in.nextInt();
        int M = in.nextInt();
        for (int i = 1; i <= n; i++) {
            int v = in.nextInt();
            int m = in.nextInt();
            int w = in.nextInt();
            for (int j = V; j >= v; j--) {
                for (int k = M; k >= m; k--) {
                    f[j][k] = Math.max(f[j][k], f[j - v][k - m] + w);
                }
            }
        }
        System.out.println(f[V][M]);
    }
}
